{{ $type := .type }}

{{ $host := site.Data.social.mastodon.host }}
{{ $username := site.Data.social.mastodon.username }}

{{ with $host }}
{{ else }}{{ errorf "Missing Required parameter name [ social.mastodon.host ]: %s" .Position }}
{{ end }}

{{ with $username }}
{{ else }}{{ errorf "Missing Required parameter name [ social.mastodon.username ]: %s" .Position }}
{{ end }}

{{ with $type }}
{{ else }}{{ errorf "Missing Required parameter name [ type ]: %s" .Position }}
{{ end }}

{{ $prefix := "https://" }}
{{ $at := "@" }}
{{ $result := "" }}

{{ if eq $type "url" }}
    {{ $url := printf "%s%s/%s%s" $prefix $host $at $username | safeHTML }}
    {{ $result = $url }}
{{ end }}

{{ if eq $type "account" }}
    {{ $account := printf "%s%s%s%s" $at $username $at $host | safeHTML }}
    {{ $result = $account }}
{{ end }}

{{ return $result }}